package com.ruicar.afs.cloud.bizcommon.voucher.service.impl;


import com.ruicar.afs.cloud.bizcommon.voucher.mq.sender.VoucherFlowSender;
import com.ruicar.afs.cloud.bizcommon.voucher.service.VoucherFlowService;
import com.ruicar.afs.cloud.common.modules.dto.mq.voucher.VoucherFlowInfoDto;
import com.ruicar.afs.cloud.common.mq.rabbit.message.AfsTransEntity;
import com.ruicar.afs.cloud.common.mq.rabbit.message.MqTransCode;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.text.MessageFormat;

/**
 * @author infinity
 * @version 1.0
 * @date 2020/7/11 15:48
 */
@Service
@Slf4j
@AllArgsConstructor
public class VoucherFlowServiceImpl implements VoucherFlowService {

    private final VoucherFlowSender voucherFlowSender;

    public boolean sendFlow(VoucherFlowInfoDto voucherFlowInfoDto) {
        log.info(MessageFormat.format("凭证埋点编号：{0}，业务流水号：{1} ，流水信息推送", voucherFlowInfoDto.getBuriedPointNo(), voucherFlowInfoDto.getTransNo()));
        AfsTransEntity<VoucherFlowInfoDto> entity = new AfsTransEntity<>();
        entity.setData(voucherFlowInfoDto);
        entity.setTransCode(MqTransCode.AFS_VOUCHER_FLOW_PUSH);
        voucherFlowSender.sendVoucherFlowToAccount(entity);
        return Boolean.TRUE;
    }

}
